{extend name="base" /}
{block name="content"}
<script src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>


    <div class="m-main-content">
        <div class="m-container">

            <form class="layui-form m-list-form">
                <table class="m-table">
                    <tbody class="datas">
                    <tr>
                        <th width="5%">ID</th>
                        <th width="10%">规格名称</th>
                        <th width="10%">规格原价格</th>
                        <th width="10%">角色价格</th>
                        <th width="10%">库存</th>
                    </tr>
                    {foreach name="sku_list" item="v"}
                    <tr>
                        <td>{$v.id}</td>
                        <td>{$v.sku_name}</td>
                        <td>{$v.sale_price}</td>
                        <td>
                            <input type="text" class="u-ipt u-ipt-small rsku_price" data-id="{$v.id}" name="rsku_price"  placeholder="请输入角色价格" value="{$v.rsku_price|default=0}" />元,<span style="color:#CCCCCC;">未设置价格，默认商品正常价格</span></td>
                        <td>{$v.stock}</td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </form>

        </div>
    </div>
{/block}{block name="extrajs"}

<script>
    $(function(){
        layui.use('layer', function(){
            $('.rsku_price').on('change',function () {
                var sku_id =$(this).attr('data-id');//角色id
                var role_id="{$role_id}";
                var goods_id="{$goods_id}";
                var rsku_price=$(this).val();

                $.post('/manage/role_goods/setSkuPrice',{role_id:role_id,sku_id:sku_id,goods_id:goods_id,sale_price:rsku_price},function (res) {
                    if(res.code===1){
                        layer.msg(res.msg)
                    }else{
                        layer.msg(res.msg)
                    }
                })
            })
        });
    });
</script>
{/block}